using UnityEngine;

public abstract class DrawableGameObject : MonoBehaviour {

    protected GameAnimation gameAnimation;
    protected Vector3 scale;

    private Texture2D[] standAnimation, runAnimation, jumpAnimation, crouchAnimation, attackAnimation;

    protected void SetAnimations(Texture2D[] standAnimation, Texture2D[] runAnimation, Texture2D[] jumpAnimation, Texture2D[] crouchAnimation, Texture2D[] attackAnimation)
    {
        this.standAnimation = standAnimation;
        this.runAnimation = runAnimation;
        this.jumpAnimation = jumpAnimation;
        this.crouchAnimation = crouchAnimation;
		this.attackAnimation = attackAnimation;
    }

	public virtual void Start () 
    {
        gameAnimation = GetComponent<GameAnimation>();
        scale = transform.localScale;
	}

    protected void RunAnimation(string animation, string animationMode)
    {
        if (gameAnimation.currentAnimation != animation)
        {
            gameAnimation.currentAnimation = animation;

            switch (animation)
            {
                case "Stand":
                    gameAnimation.AddAnimation(standAnimation, animationMode);
                    gameAnimation.Play();
                    break;
                case "Run":
                    gameAnimation.AddAnimation(runAnimation, animationMode);
                    gameAnimation.Play();
                    break;
                case "Jump":
                    gameAnimation.AddAnimation(jumpAnimation, animationMode);
                    gameAnimation.Play();
                    break;
                case "Crouch":
                    gameAnimation.AddAnimation(crouchAnimation, animationMode);
                    gameAnimation.Play();
                    break;
				case "Attack":
                    gameAnimation.AddAnimation(attackAnimation, animationMode);
					gameAnimation.Play();
					break;
                default:
                    break;
            }
        }
    }

    protected void StopAnimation()
    {
        if (gameAnimation.isPlaying())
        {
            gameAnimation.Stop();
        }
    }
    
}
